home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Graphics / Viewers / aa_m68k_Intel_Only / ToyViewer1.2 / Source / ADSlave.m < prev    next >
Encoding:
Text File  |  1995-11-12  |  1.1 KB  |  62 lines

  1. #import "ADSlave.h"
  2. #import "ADController.h"
  3. #import "TVController.h"
  4. #import "strfunc.h"
  5.  
  6. #define  WinBufSIZE    4
  7.  
  8. static id windowBuffer[WinBufSIZE];
  9. static int    wbp = 0;
  10.  
  11. @implementation ADSlave
  12.  
  13. - init:sender with:controller dir:(const char *)path
  14. {
  15.     adCtrl = sender;
  16.     tvCtrl = controller;
  17.     directory = str_dup(path);
  18.     return self;
  19. }
  20.  
  21. - free
  22. {
  23.     free((void *)directory);
  24.     [super free];
  25.     return nil;
  26. }
  27.  
  28. - donext: sender
  29. {
  30.     const char *nextfile;
  31.     char    fn[MAXFILENAMELEN];
  32.     id    tw, oldtw, win;
  33.     int    n;
  34.  
  35.     if ((nextfile = [adCtrl nextFilename]) == NULL) {
  36.         [adCtrl continueLoop:NO];
  37.         return nil;
  38.     }
  39.     sprintf(fn, "%s/%s", directory, nextfile);
  40.     if ([tvCtrl isOpened: fn]) { /* already opened */
  41.         [adCtrl continueLoop:YES];
  42.         return self;
  43.     }
  44.     n = getExtension(nextfile);
  45.     tw = [tvCtrl drawFile: fn : &nextfile[n]];
  46.     if (tw) {
  47.         oldtw = windowBuffer[wbp];
  48.         if (oldtw != nil && [tvCtrl checkWindow:oldtw delete:NO]) {
  49.             win = [oldtw window];
  50.             if ([win counterpart] == nil)
  51.                 /* has not been miniaturized */
  52.                 [win performClose: self];
  53.         }
  54.         windowBuffer[wbp] = tw;
  55.         wbp = (wbp + 1) % WinBufSIZE;
  56.     }
  57.     [adCtrl continueLoop:YES];
  58.     return self;
  59. }
  60.  
  61. @end
  62.